<template>
  <div class="home-view">
    <!-- 顶部导航栏 -->
    <el-header class="main-header">
      <nav class="main-nav">
        <router-link to="/user" class="nav-link">
          <el-icon><User /></el-icon>
          <span>用户管理</span>
        </router-link>
        <router-link to="/todo" class="nav-link">
          <el-icon><Document /></el-icon>
          <span>代办事件管理</span>
        </router-link>
        <router-link to="/chat" class="nav-link">
          <el-icon><ChatDotRound /></el-icon>
          <span>智能问答</span>
        </router-link>
      </nav>
      <!-- 头像管理按钮 -->
      <el-button class="avatar-button" @click="toggleAvatarManagement">
        <el-icon><Avatar /></el-icon>
        <span>头像管理</span>
      </el-button>
    </el-header>

    <!-- 主内容区域 -->
    <el-main class="main-content">
      <!-- 头像管理组件 -->
      <AvatarManagement
          v-if="showAvatarManagement"
          class="avatar-management"
          @close="showAvatarManagement = false"
      />

      <!-- 路由内容 -->
      <div class="router-content">
        <router-view></router-view>
      </div>
    </el-main>

    <!-- 底部信息栏 -->
    <el-footer class="main-footer">
      <div class="footer-content">
        <span>© 2025 后台管理系统</span>
        <el-link type="info" href="#" :underline="false">隐私政策</el-link>
        <el-link type="info" href="#" :underline="false">服务条款</el-link>
      </div>
    </el-footer>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { User, ChatDotRound, Document, Avatar } from '@element-plus/icons-vue';
import AvatarManagement from '@/components/AvatarManagement.vue'; // 引入头像管理组件

// 控制头像管理组件的显示与隐藏
const showAvatarManagement = ref(false);

// 切换头像管理组件的显示状态
const toggleAvatarManagement = () => {
  showAvatarManagement.value = !showAvatarManagement.value;
};
</script>

<style scoped>
/* 样式保持不变 */
</style>


<style scoped>
.home-view {
  display: flex;
  flex-direction: column;
  height: 92vh;
  overflow: hidden;
  background: var(--bg-color);
}

.main-header {
  background: var(--card-bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  padding: 0 24px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between; /* 将导航栏和头像管理按钮分开 */
}

.main-nav {
  display: flex;
  gap: 20px;
  padding: 12px 0;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 16px 32px;
  border-radius: 12px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 500;
  background: rgba(64, 158, 255, 0.05);
  border: 1px solid rgba(64, 158, 255, 0.1);
}

.nav-link:hover {
  color: var(--primary-color);
  background: rgba(64, 158, 255, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.1);
}

.router-link-exact-active {
  color: #fff;
  background: var(--primary-color);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.2);
}

.router-link-exact-active:hover {
  background: #66b1ff;
}

.avatar-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(64, 158, 255, 0.1);
  border: 1px solid rgba(64, 158, 255, 0.2);
  color: var(--primary-color);
  transition: all 0.3s ease;
}

.avatar-button:hover {
  background: rgba(64, 158, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.1);
}

.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}

.avatar-management {
  position: fixed;
  top: 100px; /* 距离顶部的高度 */
  right: 24px; /* 距离右侧的距离 */
  z-index: 1000; /* 确保组件显示在最上层 */
}

.router-content {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.main-footer {
  background: var(--card-bg);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
  padding: 16px 24px;
  text-align: center;
  height: 40px;
}

.footer-content {
  display: flex;
  justify-content: center;
  gap: 20px;
}
</style>